import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/material.dart';

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  _IndexState createState() => _IndexState();
}

class _IndexState extends State<HomePage> {
  Widget getSwiper() {
    return CarouselSlider(
      items: [
        Image.network(
          "https://img2.baidu.com/it/u=751773882,1290172297&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
          fit: BoxFit.cover,
        ),
        Image.network(
          "https://img0.baidu.com/it/u=4243928860,573227806&fm=253&fmt=auto&app=120&f=JPEG?w=1280&h=800",
          fit: BoxFit.cover,
        ),
        Image.network(
          "https://img0.baidu.com/it/u=2290894967,2752394478&fm=253&fmt=auto&app=120&f=JPEG?w=1280&h=800",
          fit: BoxFit.cover,
        ),
        Image.network(
          "https://img2.baidu.com/it/u=667247897,766454330&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
          fit: BoxFit.cover,
        )
      ],
      options: CarouselOptions(
          height: 200, autoPlay: true, autoPlayInterval: Duration(seconds: 1)),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: [
          getSwiper() // 轮播图
        ],
      ),
    );
  }
}
